#!/bin/bash

# 检查输入参数是否足够
if [[ $# -lt 2 ]]; then
    echo "错误：请输入两个参数。"
    echo "用法：$0 <cc> <number>"
    exit 1
fi

# 获取输入的参数
cc=$1
number=$2

# 回显即将执行的命令
echo "即将执行以下命令："
for wl in $(seq 10 10 90); do
    echo "nohup ./waf --run \"scratch/third input/config_${cc}_${wl}.txt ${wl}_${number}\" > log/run_${cc}_${wl}_${number}.log 2>&1 &"
done


# 确认是否执行命令
read -p "确认执行以上命令吗? (y/n): " confirm
if [[ "$confirm" != "y" && "$confirm" != "Y" ]]; then
    echo "取消执行。"
    exit 0
fi

# 执行命令
echo "Building"
./waf build > /dev/null 2>&1
echo "Building Finished."
for wl in $(seq 10 10 90); do
    nohup ./waf --run "scratch/third input/config_${cc}_${wl}.txt ${wl}_${number}" > log/run_${cc}_${wl}_${number}.log 2>&1 &
    sleep 1.5
    tail -n 1 log/run_${cc}_${wl}_${number}.log
done

# 提示执行完成
echo "命令已执行完毕"
